#include "parameters_widget.h"
#include <QLabel>
#include <QLineEdit>
#include <QDebug>
#include <QCheckBox>
#include <QComboBox>

ParametersWidget::ParametersWidget(QWidget* parent)
    : QWidget(parent)
{
    layout = new QFormLayout(this);
}

ParametersWidget::~ParametersWidget()
{
    delete layout;
}

void ParametersWidget::loadParameters(const ParameterList& paramList)
{

    mili::CAutonomousIterator<ParameterList> it(paramList);
    while (!it.end())
    {
        int i = 0;
        QString value = QString::fromStdString((*it)->get_tag());
        QString info = QString::fromStdString((*it)->get_info());

        QLabel* label = new QLabel(value);
        label->setObjectName(value);

        if (info == "bool")
        {
            QCheckBox* param = new QCheckBox;
            param->setObjectName(value);
            param->setObjectName(value);
            layout->insertRow(i, label, param);

        }
        else if (info == "int" || info == "float" || info == "double")
        {
            QLineEdit* param = new QLineEdit;
            param->setObjectName(value);
            param->setObjectName(value);
            layout->insertRow(i, label, param);

        }
        else
        {
            QComboBox* param = new QComboBox;
            param->insertItem(0, "PI");
            param->insertItem(1, "NRTI");
            param->insertItem(2, "NNRTI");
            param->setObjectName(value);
            param->setObjectName(value);
            layout->insertRow(i, label, param);
        }
        ++i;
        ++it;
    }
}
